package com.tester.yaa.exam002.threadLocal;

/**
 * @Aduthor yinanan
 * @ClassName ConsumerThread
 * @Date 2022/12/11 18:46
 * @Description 消费者
 **/
public class ConsumerThread implements Runnable {
    @Override
    public void run() {
        while (true) {
            synchronized (Test.object) {
                try {
                    //唤醒等待的（生产者）线程
                    Test.object.notify();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                if (!Test.flag) {
                    System.out.println(Thread.currentThread().getName() + "已消费完....");
                    Test.flag = true;
                }
            }
        }
    }
}
